package domain;

import org.joda.time.DateTime;

import java.util.UUID;

/**
 * Created by zhifu on 2015/3/25.
 */
public abstract class AbstractDomain {
    protected  Integer id;
    protected boolean archived;
    protected String guid = UUID.randomUUID().toString();
    protected  Integer version=0;
    protected DateTime creationTime = new DateTime();

    @Override
    public boolean equals(Object obj) {
        if(this == obj){
            return true;
        }
        if(!(obj instanceof AbstractDomain)){
            return false;
        }
        AbstractDomain domain = (AbstractDomain)obj;
        return this.guid.equals(domain.guid);
    }

    @Override
    public int hashCode() {
        return guid.hashCode();
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public boolean isArchived() {
        return archived;
    }

    public void setArchived(boolean archived) {
        this.archived = archived;
    }

    public String getGuid() {
        return guid;
    }

    public void setGuid(String guid) {
        this.guid = guid;
    }

    public Integer getVersion() {
        return version;
    }

    public void setVersion(Integer version) {
        this.version = version;
    }

    public DateTime getCreationTime() {
        return creationTime;
    }

    public void setCreationTime(DateTime creationTime) {
        this.creationTime = creationTime;
    }
}
